/**
 * Created by zhangqiang on 16/12/02.
 */
import PullRefresh from '../components/mui/PullRefresh.js';


const lf = liefeng,
    R = React,
    RC = React.createClass,
    log = lf.utils.log,
    ajax = lf.utils.ajax,
    fmt = 'yyyy-MM-dd hh:mm:ss',
    imgPre = '../public/images/finger/',
    formatTime = lf.utils.format;

const Product = RC({
    getInitialState() {
        return {}
    },
    componentDidMount() {

    },
    render() {
        let data = this.props.data,
            time = formatTime(data.createTime, fmt), //todo 注意:居然只能是数字而不是字符串
            type = '',
            btns = [],
            color = '';


        return <div className="product-switch">
                    <div className="mui-input-row mui-radio jeep add">
                        <label>{data.productName}</label>
                         <img src={imgPre+data.img||'../public/images/common/none.png'} alt=""/>
                        <input name="radio1" type="radio"/>
                    </div>
                </div>
    }
});

const Root = RC({
    getInitialState() {
        return {}
    },
    componentDidMount() {
        
        
    },
    render() {
        let data = [
                {
                    productName: '皇家富士苹果',
                    img: 'apple.jpg',
              },{
                    productName: '皇家富士苹果',
                    img: 'apple.jpg',
                }
            ],
            list = data.map((info, i)=> {
                return <Product data={info} key={i}/>
            })

        return <div className="switch">
                   <div className="box">
                        {list}
                  </div>
                </div>
    }
});

lf.appJs.getUser(function (user) {
    R.render(<PullRefresh data={<Root user={user}/>}/>, document.getElementById('root'),
        function () {
            $('#root').css({
                'background': '#ededed',
            });
        }
    );
});